﻿#region
/*******************************************************************************
** File Name:		    AdminUserGroupService.cs
** Creator:		        chao.jiang 
** EMail:               chao.jiang 
** Create date:	        
** Latest Modifier:
** Latest Modify date:
** Description:		    
** Modify History:
**
** Code Review:
**
** Version number:       1.0.0
*********************************************************************************/
#endregion
using System;
using System.Collections.Generic;
using System.Text;
using Phoenix.Service.Contracts;
using Phoenix.Service.Model;
using Phoenix.IBatisRepository;
using Phoenix.Respository;
using System.Data;
using Phoenix.Entity;

namespace Phoenix.Service
{
    public class AdminUserGroupService : IAdminUserGroupService 
    {
		 IAdminUserGroup adminUserGroup = new AdminUserGroupRepository();
		 
		 #region  Auto Generation
		 
        public void AddAdminUserGroup(AdminUserGroupModel model)
        {
			EAdminUserGroup entity = ConvertModelToEntity(model);
			
            adminUserGroup.AddAdminUserGroup(entity);
        }

		public void UpdateByAdminUserGroupID (AdminUserGroupModel model)
		{
			EAdminUserGroup entity = ConvertModelToEntity(model);

            adminUserGroup.UpdateByAdminUserGroupID(entity);

		}

		public void DeleteByAdminUserGroupID (System.Int32 adminUserGroupID)
		{
		
            adminUserGroup.DeleteByAdminUserGroupID(adminUserGroupID);

		}
		 
        public AdminUserGroupModel GetByAdminUserGroupID (System.Int32 adminUserGroupID)
        {
        
			EAdminUserGroup entity = adminUserGroup.GetByAdminUserGroupID(adminUserGroupID);
			
            AdminUserGroupModel model = ConvertEntityToModel(entity);


            return model;
        }
        
		public AdminUserGroupModel ConvertEntityToModel(EAdminUserGroup entity)
		{
			if (entity == null)
            {
                return null;
            }
			AdminUserGroupModel model = new AdminUserGroupModel();
                        model.AdminUserGroupID = entity.AdminUserGroupID;
                        model.UserID = entity.UserID;
                        model.GroupID = entity.GroupID;
                        return model;
		}
		
		public EAdminUserGroup ConvertModelToEntity(AdminUserGroupModel model)
		{
			if (model == null)
            {
                return null;
            }
			EAdminUserGroup entity = new EAdminUserGroup();
                        entity.AdminUserGroupID = model.AdminUserGroupID;
                        entity.UserID = model.UserID;
                        entity.GroupID = model.GroupID;
                        return entity;
		}
		
		#endregion
    }
}